#include <bits/stdc++.h>
#include <iterator>
using namespace std;
#define ll int
const ll N=1e6+10;
struct node{
    ll l,r;
    set<ll> rc;
    ll sum;
}qrov[N];
ll T,n,m,L,V;
ll f[N];
ll spch[N],ans,cnt;
bool if_ch[N];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","W",stdout);
    cin>>T;
    while(T--){
        cnt=ans=0;
        cin>>n>>m>>L>>V;
        for(ll i=1;i<=n;i++){
            qrov[i].rc.clear();
            ll loc,fspd,addv;
            cin>>loc>>fspd>>addv;
            if(fspd<=V&&addv<=0){
                qrov[i].l=-1;
                qrov[i].r=-1;
                continue;
            }
            if(fspd>V&&addv>=0){
                qrov[i].l=loc;
                qrov[i].r=L;
                continue;
            }
            double p=(double)(V*V-fspd*fspd)/(double)(addv*2)+(double)loc;
            if(fspd>V&&addv<0){  //down
                qrov[i].l=loc;
                qrov[i].r=min(L,(ll)p);
                if(p==(ll)p) qrov[i].r--;
                continue;
            }
            if(fspd<=V&&addv>0){  //up
                if(p>L){
                    qrov[i].l=-1;
                    qrov[i].r=-1;
                }
                else{
                    qrov[i].l=ceil(p);
                    qrov[i].r=L;
                }
                continue;
            }
        }
        for(ll i=1;i<=m;i++){
            ll k;
            cin>>k;
            if_ch[k]=1;
        }
        for(ll i=1;i<=n;i++){
            bool fk=0;
            if(qrov[i].l==-1) continue;
            for(ll j=qrov[i].l;j<=qrov[i].r;j++){
                if(if_ch[j]){
                    qrov[i].rc.insert(j);
                    qrov[i].sum++;
                    if(!fk){
                        ans++;
                        fk=1;
                    }
                }
            }
        }
        cout<<ans<<" ";
        cout<<ans<<endl;
    }
    return 0;
}
